package com.classtwo.colleage.controler;

import com.classtwo.colleage.conf.DatabaseUser_classInfo;
import com.classtwo.colleage.model.Student;
import com.classtwo.colleage.model.User_class;
import com.classtwo.colleage.tool.ExcelHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@Controller

public class DownloadExcel {



    @Autowired
    private DatabaseUser_classInfo classInfo;
    @RequestMapping("/downloadExcel")
    public void export(HttpServletResponse response, String Excelname, String Exceltitle, String ExcelsheetName ){

        String Excelsuffex = ".xls";
        String Excelname1 = Excelname;
        String Excelname2= Excelname+Excelsuffex;
        String Exceltitle1 = Exceltitle;
        String ExcelsheetName1 = ExcelsheetName;


        List<User_class> stulist = classInfo.findByUsertype("学生");


      /*  //模拟从数据库获取需要导出的数据
        List<StudentVo> studentList = new ArrayList<>();
        StudentVo student1=new StudentVo("王晓峰", "1");
        StudentVo student2=new StudentVo("黄仲浩", "2");
        StudentVo student3=new StudentVo("刘东", "3");
        StudentVo student4=new StudentVo("叶俊波", "4");

        studentList.add(student1);
        studentList.add(student2);
        studentList.add(student3);
        studentList.add(student4);*/

        ExcelHandler.exportExcel(stulist,Exceltitle1,ExcelsheetName1,User_class.class,Excelname2,response);
        //导出操作
/*        FileUtil.exportExcel(personList,"花名册","草帽一伙",Person.class,"海贼王.xls",response);*/



    }





}
